//*
// * To change this template, choose Tools | Templates
// * and open the template in the editor.
// */
package MemberOperation;

import CRUD.ForumHome;
import CRUD.MemberHome;
import beans.MarkLurk;
import java.util.Set;
import xmlMapping.Forum;
import xmlMapping.Member;

/**
 *
 * @author labib
 */
public class MemberForumOperation {

    public static void setForumMark(MarkLurk m) {
        Set markers = null;
        ForumHome home = new ForumHome();
        Forum forum = home.findById(m.getId());
        try {
            markers = forum.getMembers_1();
        } finally {
            Member mem = new Member();
            mem.setMemberId(new Integer(m.getMemberId()));
            markers.add(mem);
            forum.setMembers_1(markers);
            home.attachDirty(forum);
        }
    }
    public static void removeForumMark(MarkLurk m) {
        ForumHome forumHome = new ForumHome();
        Forum forum = forumHome.findById(m.getId());
        Set markers = forum.getMembers_1();
        MemberHome memHome = new MemberHome();
        Member member = memHome.findById(m.getMemberId());
        markers.remove(member);
        forum.setMembers_1(markers);
        forumHome.attachDirty(forum);
    }

//    public static void main(String[] args) {
////        RankPost(1, 1,3);
//        MarkLurk m = new MarkLurk();
//        m.setId(1); //threead id
//        m.setMemberId(3);
//        //setForumMark(m);
//        removeForumMark(m);
//    }
}
